//
//  HMCaseViewController.m
//  仿真开发
//
//  Created by B.HOPE on 2017/3/24.
//  Copyright © 2017年 B.HOPE. All rights reserved.
//

#import "HMCaseViewController.h"
#import <Masonry.h>
#import <YYModel.h>
#import <HMImagePickerController.h>
#import "HMTool.h"
#import "HMAddCaseCell.h"
#import "HMAddCaseTwoCell.h"
#import "HMCaseTwoModel.h"
#import "HMCaseManageModel.h"
#import "HMAddCaseController.h"
#import "HMCaseListController.h"
#import "HMCaseListTwoController.h"
#import "HMCaseManageCollectionCell.h"

@interface HMCaseViewController () <UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate,UIImagePickerControllerDelegate,UICollectionViewDelegate,UICollectionViewDataSource,HMCaseListControllerDelegate,HMCaseListTwoControllerDelegate,HMAddCaseTwoCellDelegate,HMAddCaseControllerDelegate,HMImagePickerControllerDelegate>

/**
 病类数据
 */
@property (nonatomic, strong) NSArray *arrayModel;

/**
 病症类型
 */
@property (nonatomic, strong) NSArray *arrayModelTwo;

/**
 接收返回的病类
 */
@property (nonatomic, strong) NSString *virustype;

/**
 接收返回的病症
 */
@property (nonatomic, strong) NSString *symptom;

/**
 第一条CELL的模型数组
 */
@property (nonatomic, strong) NSArray *arrayCell;

/**
 第二条CELL的模型数组
 */
@property (nonatomic, strong) NSArray *arrayCellTwo;

/**
 接收返回的标签
 */
@property (nonatomic, strong) NSArray *arrayAddCase;

/**
 准备返回的全部的数据数组
 */
@property (nonatomic, strong) NSMutableArray *allModel;


@property (nonatomic, strong) UITableView *tabView;
@property (nonatomic, strong) UICollectionView *collection;


/**
 图片的按钮
 */
@property (nonatomic, strong) UIButton *imgBtn1;
@property (nonatomic, strong) UIButton *imgBtn2;
@property (nonatomic, strong) UIButton *imgBtn3;

/**
 记录点击按钮的TAG
 */
@property (nonatomic, assign) NSInteger btnNum;

/**
 删除图片的按钮
 */
@property (nonatomic, strong) UIButton *deleBtn1;
@property (nonatomic, strong) UIButton *deleBtn2;
@property (nonatomic, strong) UIButton *deleBtn3;

// 选中照片数组
@property (nonatomic) NSMutableArray<UIImage *> *images;
// 选中资源素材数组，用于定位已经选择的照片
@property (nonatomic) NSArray<PHAsset *> *selectedAssets;


@property (nonatomic, strong) HMCaseManageAllModel *skipModel;

@end

static NSString *caseCell = @"cell";

static NSString *caseCell2 = @"caseCell2";

@implementation HMCaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
//    //创建一个图片的空数组
//    //创建一个PHAssets的空数组
//    NSMutableArray *assets = [NSMutableArray array];
//    
//    //从沙盒中读取到PHAsset的identifier的数组
//    NSString *imagePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject stringByAppendingPathComponent:@"images"];
//    NSLog(@"%@", imagePath);
//    NSArray *localIdentifieArray = [NSKeyedUnarchiver unarchiveObjectWithFile:imagePath];
//    
//    //遍历identifier的数组, 生成PHAsset的数组
//    PHFetchResult *phFetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:localIdentifieArray options: nil];
//    [phFetchResult enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx,BOOL *_Nonnull stop) {
//        [assets addObject: obj];
//    }];
//    
//    _selectedAssets = assets;
//    
//    //遍历PHAsset的数组生成图片的数组
//    for (PHAsset *asset in _selectedAssets) {
//        [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:CGSizeMake(200, 200) contentMode:PHImageContentModeDefault options:nil resultHandler:^(UIImage * _Nullable image, NSDictionary * _Nullable info) {
//            [_images addObject:image];
//        }];
//    }
//    
//    //更新UI
//    [self.collection reloadData];
//    
    
    
    
    
    
    _model = [[HMCaseManageAllModel alloc] init];
    _model.arrayImg = [[NSMutableArray alloc] init];
    _arrayModel = @[@"脑肿瘤",@"血液病",@"心脑血管病",@"神经系统",@"骨科"];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupUI];
}

- (void)setupUI
{
    UIBarButtonItem *yesBtn = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(clickBtn:)];
    yesBtn.tag = 1;
    
    UIBarButtonItem *noBtn = [[UIBarButtonItem alloc] initWithTitle:@"删除" style:UIBarButtonItemStylePlain target:self action:@selector(clickBtn:)];
    noBtn.tag = 0;
    
    self.navigationItem.rightBarButtonItems = @[yesBtn,noBtn];
    
    _tabView = [[UITableView alloc] init];
    [self.view addSubview:_tabView];
    [_tabView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    _tabView.delegate = self;
    _tabView.dataSource = self;
    
    [_tabView registerClass:[HMAddCaseCell class] forCellReuseIdentifier:caseCell];
    [_tabView registerClass:[HMAddCaseTwoCell class] forCellReuseIdentifier:caseCell2];
    
    _tabView.estimatedRowHeight = 200;
    
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.itemSize = CGSizeMake(110, 110);
    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    
    _collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 300) collectionViewLayout:layout];
    
    _collection.backgroundColor = [UIColor whiteColor];
    
    
    _tabView.tableFooterView = _collection;
    
    _collection.dataSource = self;
    _collection.delegate = self;
    
    [_collection registerClass:[HMCaseManageCollectionCell class] forCellWithReuseIdentifier:@"coll"];
    
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 300)];
//    view.backgroundColor = [UIColor whiteColor];
//    _tabView.tableFooterView = view;
//    
//    UILabel *label = [[UILabel alloc] init];
//    label.text = @"病例图片";
//    label.font = [UIFont systemFontOfSize:16];
//    [view addSubview:label];
//    [label mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.left.offset(10);
//    }];
//    
//    _imgBtn1 = [[UIButton alloc] init];
//    _imgBtn1.tag = 11;
//    [_imgBtn1 setImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
//    [view addSubview:_imgBtn1];
//    [_imgBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(label.mas_bottom).offset(10);
//        make.left.equalTo(label);
//        make.size.mas_offset(CGSizeMake(110, 110));
//    }];
//    
//    _imgBtn2 = [[UIButton alloc] init];
//    _imgBtn2.tag = 12;
//    [_imgBtn2 setImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
//    [view addSubview:_imgBtn2];
//    [_imgBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(_imgBtn1);
//        make.left.equalTo(_imgBtn1.mas_right).offset(10);
//        make.size.mas_offset(CGSizeMake(110, 110));
//    }];
//    _imgBtn2.hidden = YES;
//    
//    _imgBtn3 = [[UIButton alloc] init];
//    _imgBtn3.tag = 13;
//    [_imgBtn3 setImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
//    [view addSubview:_imgBtn3];
//    [_imgBtn3 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(_imgBtn2);
//        make.left.equalTo(_imgBtn2.mas_right).offset(10);
//        make.size.mas_offset(CGSizeMake(110, 110));
//    }];
//    _imgBtn3.hidden = YES;
//    
//    [_imgBtn1 addTarget:self action:@selector(clickViewBtn:) forControlEvents:UIControlEventTouchUpInside];
//    [_imgBtn2 addTarget:self action:@selector(clickViewBtn:) forControlEvents:UIControlEventTouchUpInside];
//    [_imgBtn3 addTarget:self action:@selector(clickViewBtn:) forControlEvents:UIControlEventTouchUpInside];
//    
//    
//    _deleBtn1 = [[UIButton alloc] init];
//    _deleBtn1.tag = 21;
//    _deleBtn1.hidden = YES;
//    [_deleBtn1 setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
//    [view addSubview:_deleBtn1];
//    [_deleBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(_imgBtn1.mas_top);
//        make.left.equalTo(_imgBtn1.mas_right);
//        make.size.mas_offset(CGSizeMake(10, 10));
//    }];
//    
//    _deleBtn2 = [[UIButton alloc] init];
//    _deleBtn2.tag = 22;
//    _deleBtn2.hidden = YES;
//    [_deleBtn2 setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
//    [view addSubview:_deleBtn2];
//    [_deleBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(_imgBtn2.mas_top);
//        make.left.equalTo(_imgBtn2.mas_right);
//        make.size.mas_offset(CGSizeMake(10, 10));
//    }];
//    
//    _deleBtn3 = [[UIButton alloc] init];
//    _deleBtn3.tag = 23;
//    _deleBtn3.hidden = YES;
//    [_deleBtn3 setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
//    [view addSubview:_deleBtn3];
//    [_deleBtn3 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(_imgBtn3.mas_top);
//        make.left.equalTo(_imgBtn3.mas_right);
//        make.size.mas_offset(CGSizeMake(10, 10));
//    }];
//    
//    [_deleBtn1 addTarget:self action:@selector(clickDeleBtn:) forControlEvents:UIControlEventTouchUpInside];
//    [_deleBtn2 addTarget:self action:@selector(clickDeleBtn:) forControlEvents:UIControlEventTouchUpInside];
//    [_deleBtn3 addTarget:self action:@selector(clickDeleBtn:) forControlEvents:UIControlEventTouchUpInside];
//    
//    if (_skip == YES)
//    {
//        [self setModelImage];
//    }
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    if (_skip == YES)
    {
        return _skipModel.arrayImg.count;
    }
    
    return _images.count == 0 ? 1 : _images.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    HMCaseManageCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"coll" forIndexPath:indexPath];
    
    
    if (_skip == YES)
    {
        cell.icon = _skipModel.arrayImg[indexPath.row];
        return cell;
    }
    
    cell.icon = _images[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    HMImagePickerController *picker = [[HMImagePickerController alloc] initWithSelectedAssets:_selectedAssets];
    
    // 设置图像选择代理
    picker.pickerDelegate = self;
    // 设置目标图片尺寸
    picker.targetSize = CGSizeMake(600, 600);
    // 设置最大选择照片数量
    picker.maxPickerCount = 3;
    
    [self presentViewController:picker animated:YES completion:nil];
}

- (void)imagePickerController:(HMImagePickerController *)picker
      didFinishSelectedImages:(NSArray<UIImage *> *)images
               selectedAssets:(NSArray<PHAsset *> *)selectedAssets {
    
    // 记录图像，方便在 CollectionView 显示
    
    _images = [NSMutableArray array];
    
    
    [self.images removeAllObjects];
    [self.images addObjectsFromArray:images]; //图片保存在沙盒里面
    // 记录选中资源集合，方便再次选择照片定位
    self.selectedAssets = selectedAssets;
    
    NSString *imagePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject stringByAppendingPathComponent:@"images"];
    NSLog(@"%@", imagePath);
    
    NSMutableArray *localIdentifierArr = [NSMutableArray  array];
    for (PHAsset *phAsset  in  _selectedAssets) {
        [localIdentifierArr  addObject: phAsset.localIdentifier ];
    }
    
    [NSKeyedArchiver archiveRootObject:localIdentifierArr toFile:imagePath];
    
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];   [formatter setDateFormat:@"yyy-MM-dd hh:mm:ss"];
    NSString *dateTime = [formatter stringFromDate:[NSDate date]];
    
    _model.time = dateTime;
    [_model.arrayImg addObjectsFromArray:_images];
  
    [self.collection reloadData];
    
    [self dismissViewControllerAnimated:YES completion:nil];
}










- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row <= 1)
    {
        HMAddCaseCell *cell = [tableView dequeueReusableCellWithIdentifier:caseCell forIndexPath:indexPath];
        
        if (indexPath.row == 0)
        {
            cell.model = _arrayCell[indexPath.row];
            return  cell;
        }
        
        cell.twoModel = _arrayCellTwo.lastObject;
        
        return cell;
    }
    
    HMAddCaseTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:caseCell2 forIndexPath:indexPath];
    cell.delegate =self;
    
    cell.arrayModel = _arrayAddCase;
    //取消点击效果
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (void)clickBtn:(UIButton *)sender
{
    if (sender.tag == 0)
    {
        if (_skip == YES)
        {
            [self.delegate caseViewController:self Model:nil Num:_arrayNum];
            
            [self.navigationController popViewControllerAnimated:YES];
            
            return;
        }
        
        [self.navigationController popViewControllerAnimated:YES];
    }
    else
    {
        
        if (_skip == NO)
        {
            [self.delegate caseViewController:self Model:_model Num:-1];
            
        } else {
            
            [self.delegate caseViewController:self Model:_skipModel Num:-1];
        }
        
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        HMCaseListController *tab = [[HMCaseListController alloc] init];
        tab.array = _arrayModel;
        tab.delegate = self;
        [self.navigationController pushViewController:tab animated:YES];
    }
    
    if (indexPath.row == 1)
    {
        if (_virustype == nil)
        {
            UIAlertController *alertVc =[UIAlertController alertControllerWithTitle:@"提示" message:@"请选择疾病类型" preferredStyle:UIAlertControllerStyleAlert];
            [alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {    }]];
            [self presentViewController:alertVc animated:NO completion:nil];
        }
        else
        {
            HMCaseListTwoController *tab = [[HMCaseListTwoController alloc] init];
            tab.delegate = self;
            tab.array = _arrayModelTwo;
            [self.navigationController pushViewController:tab animated:YES];
        }
    }
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

//代理方法
- (void)caseList:(HMCaseListController *)vc Title:(NSString *)title
{
    _virustype = title;
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setObject:_virustype forKey:@"rightLabel"];
    
    HMCaseManageModel *model = [[HMCaseManageModel alloc] init];
    [model setValuesForKeysWithDictionary:dict];
    
    _arrayCell = [NSArray arrayWithObject:model];
    
    [self loadData];
    [_tabView reloadData];
    
    _model.virustype = _virustype;
}

- (void)caseListTwo:(HMCaseListTwoController *)vc Title:(NSString *)title
{
    _symptom = title;
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setObject:_symptom forKey:@"ci3_name"];
    
    HMCaseTwoModel *model = [[HMCaseTwoModel alloc] init];
    [model setValuesForKeysWithDictionary:dict];
    
    _arrayCellTwo = [NSArray arrayWithObject:model];
    
    [_tabView reloadData];
    
    _model.symptom = _symptom;
}

- (void)addCase:(HMAddCaseController *)vc Array:(NSArray *)array
{
    _arrayAddCase = [NSArray arrayWithArray:array];
    
    [_tabView reloadData];
    
    _model.arrayAddCase = [NSArray arrayWithArray:_arrayAddCase];
}

- (void)addCaseTwo:(HMAddCaseTwoCell *)vc Title:(UIButton *)sender
{
    HMAddCaseController *avc = [[HMAddCaseController alloc] init];
    avc.delegate = self;
    avc.array = @[@"高血压",@"高血糖",@"高血脂"];
    UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    avc.navigationItem.backBarButtonItem = backBtn;
    [self.navigationController pushViewController:avc animated:YES];
}

//获取本地相册图片并赋值
//- (void)clickViewBtn:(UIButton *)sender
//{
//    UIImagePickerController *pickerController = [[UIImagePickerController alloc]init];
//    
//    _btnNum = sender.tag;
//    
//    pickerController.allowsEditing = YES;
//    
//    pickerController.sourceType =  UIImagePickerControllerSourceTypeSavedPhotosAlbum;
//    
//    pickerController.delegate = self;
//    
//    [self.navigationController presentViewController:pickerController animated:YES completion:^{
//        
//    }];
//}
//
//-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
//{
//    UIButton *button = (UIButton *)[self.view viewWithTag:_btnNum];
//    
//    UIImage *resultImage = [info objectForKey:@"UIImagePickerControllerEditedImage"];
//    
//    [button setImage:resultImage forState:UIControlStateNormal];
//    
//    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
//    
//    if (_btnNum == _imgBtn1.tag)
//    {
//        _imgBtn2.hidden = NO;
//        _deleBtn1.hidden = NO;
//        
//    } else if (_btnNum == _imgBtn2.tag) {
//        _imgBtn3.hidden = NO;
//        _deleBtn1.hidden = YES;
//        _deleBtn2.hidden = NO;
//    } else if (_btnNum == _imgBtn3.tag) {
//        _deleBtn2.hidden = YES;
//        _deleBtn3.hidden = NO;
//    }
//    
//    
//    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];   [formatter setDateFormat:@"yyy-MM-dd hh:mm:ss"];
//    NSString *dateTime = [formatter stringFromDate:[NSDate date]];
//    
//    [_model.arrayImg addObject:resultImage];
//    _model.time = dateTime;
//    
//    if (_skip == YES)
//    {
//        [_skipModel.arrayImg removeAllObjects];
//        [_skipModel.arrayImg addObject:resultImage];
//        
//        _skipModel.time = dateTime;
//    }
//    
//}

//删除图片
//- (void)clickDeleBtn:(UIButton *)sender
//{
//    if (sender.tag == 23)
//    {
//        _deleBtn3.hidden = YES;
//        _deleBtn2.hidden = NO;
//        [_imgBtn3 setImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
//        [_model.arrayImg removeLastObject];
//        [_skipModel.arrayImg removeLastObject];
//    } else if (sender.tag == 22) {
//        _deleBtn2.hidden = YES;
//        _deleBtn1.hidden = NO;
//        _imgBtn3.hidden = YES;
//        [_imgBtn2 setImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
//        [_model.arrayImg removeLastObject];
//        [_skipModel.arrayImg removeLastObject];
//    } else if (sender.tag == 21) {
//        _deleBtn1.hidden = YES;
//        _imgBtn2.hidden = YES;
//        [_imgBtn1 setImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateNormal];
//        [_model.arrayImg removeLastObject];
//        [_skipModel.arrayImg removeLastObject];
//    }
//}

- (void)loadData
{
    NSInteger type = 0;
    
    if ([_virustype isEqualToString:@"脑肿瘤"]){
        type = 1;
    }else if ([_virustype isEqualToString:@"血液病"]){
        type = 2;
    }else if ([_virustype isEqualToString:@"心脑血管病"]){
        type = 3;
    }else if ([_virustype isEqualToString:@"神经系统"]){
        type = 4;
    }else if ([_virustype isEqualToString:@"骨科"]){
        type = 5;
    }
    
    NSString *strURL = @"http://iosapi.itcast.cn/doctor/searchCI3List.json.php";
    
    NSString *strPar = [NSString stringWithFormat:@"%zd",type];
    NSDictionary *parDict = @{@"page":@1,@"page_size":@15,@"ci1_id":strPar,@"keyword":@""};
    
    [[HMTool sharedNetworkTool] POSTWithURLString:strURL parameters:parDict success:^(id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSArray *array = dict[@"data"];
        NSMutableArray *arrayM = [[NSMutableArray alloc] init];
        for (NSDictionary *dict in array)
        {
            NSString *caseName = dict[@"ci3_name"];
            [arrayM addObject:caseName];
        }
        _arrayModelTwo = [NSArray arrayWithArray:arrayM];
        
        [_tabView reloadData];
        
    } faile:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

- (void)setModel:(HMCaseManageAllModel *)model
{
    
    if (_skip == NO)
    {
        return;
    }
    _model = model;
    _skipModel = [[HMCaseManageAllModel alloc] init];
    _skipModel = model;
    
    
    _virustype = model.virustype;
    NSMutableDictionary *dict1 = [[NSMutableDictionary alloc]init];
    
    [dict1 setObject:_virustype forKey:@"rightLabel"];
    HMCaseManageModel *model1 = [[HMCaseManageModel alloc] init];
    [model1 setValuesForKeysWithDictionary:dict1];
    _arrayCell = [NSArray arrayWithObject:model1];
    
    
    if (model.symptom == nil)
    {
        return;
    }
    
    _symptom = model.symptom;
    NSMutableDictionary *dict2 = [[NSMutableDictionary alloc]init];
    [dict2 setObject:_symptom forKey:@"ci3_name"];
    HMCaseTwoModel *model2 = [[HMCaseTwoModel alloc] init];
    [model2 setValuesForKeysWithDictionary:dict2];
    _arrayCellTwo = [NSArray arrayWithObject:model2];
    _arrayAddCase = [NSArray arrayWithArray:model.arrayAddCase];
    

}

//- (void)setModelImage
//{
//    if (_skipModel.arrayImg.count == 1)
//    {
//        [_imgBtn1 setImage:_skipModel.arrayImg[0] forState:UIControlStateNormal];
//        _imgBtn2.hidden = NO;
//        _deleBtn1.hidden = NO;
//        
//    } else if (_skipModel.arrayImg.count == 2) {
//        
//        [_imgBtn1 setImage:_skipModel.arrayImg[0] forState:UIControlStateNormal];
//        [_imgBtn2 setImage:_skipModel.arrayImg[1] forState:UIControlStateNormal];
//        _imgBtn2.hidden = NO;
//        _imgBtn3.hidden = NO;
//        _deleBtn2.hidden = NO;
//    } else if (_skipModel.arrayImg.count == 3) {
//        
//        [_imgBtn1 setImage:_skipModel.arrayImg[0] forState:UIControlStateNormal];
//        [_imgBtn2 setImage:_skipModel.arrayImg[1] forState:UIControlStateNormal];
//        [_imgBtn3 setImage:_skipModel.arrayImg[2] forState:UIControlStateNormal];
//        _imgBtn2.hidden = NO;
//        _imgBtn3.hidden = NO;
//        _deleBtn3.hidden = NO;
//    }
//    
//    [self.tabView reloadData];
//}





@end
